package simpledb.server.drivers;

import simpledb.file.Block;
import simpledb.server.SimpleDB;
import simpledb.tx.Transaction;

public class testDriver1 {

	public static void main(String[] args) {
		
		SimpleDB.init("dbdir");
		String fileName = "testDriver1.tbl";
		Block[] blocks = new Block[6];
		int blockOffset = 4;
		
		
		blocks[0] = new Block(fileName, 0);
		Transaction trans1 = new Transaction();
		trans1.pin(blocks[0]);
		trans1.setInt(blocks[0], blockOffset , 100);
		trans1.unpin(blocks[0]);
		trans1.commit();

		blocks[1] = new Block(fileName, 1);
		Transaction trans2 = new Transaction();
		trans2.pin(blocks[1]);
		trans2.setInt(blocks[1], blockOffset , 200);
		trans2.unpin(blocks[1]);
		trans2.commit();
		
		blocks[2] = new Block(fileName, 2);
		Transaction trans3 = new Transaction();
		trans3.pin(blocks[2]);
		trans3.setInt(blocks[2], blockOffset , 300);
		trans3.unpin(blocks[2]);
		trans3.rollback();
		
		blocks[3] = new Block(fileName, 3);
		Transaction trans4 = new Transaction();
		trans4.pin(blocks[3]);
		trans4.setInt(blocks[3], blockOffset , 400);
		trans4.unpin(blocks[3]);
		
		blocks[4] = new Block(fileName, 4);
		Transaction trans5 = new Transaction();
		trans5.pin(blocks[4]);
		trans5.setInt(blocks[4], blockOffset , 500);
		trans5.unpin(blocks[4]);
		
		blocks[5] = new Block(fileName, 5);
		Transaction trans6 = new Transaction();
		trans6.pin(blocks[5]);
		trans6.setInt(blocks[5], blockOffset , 600);
		trans6.unpin(blocks[5]);
		trans6.commit();
	}
}
